package com.match.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.match.TestSemanticAnalysis.CLibrary;
import com.match.model.DiscussModel;

public class GetKeyWordToFile {

    /**
     * @Description 获取各类型的关键字集合
     * @author xd 2018年1月25日 下午1:50:31
     * @param mapList
     * @return
     */
    public static void getTypeKey(List<DiscussModel> mapList) {
        String type1 = "F:\\keyword\\type1.txt";
        String type2 = "F:\\keyword\\type2.txt";
        String type3 = "F:\\keyword\\type3.txt";
        String type4 = "F:\\keyword\\type4.txt";
        String type5 = "F:\\keyword\\type5.txt";

        
        for (int i = 0; i < mapList.size(); i++) {
            try {
                System.out.println(mapList.get(i).getId()+"_"+mapList.get(i).getDiscuss()+"_"+mapList.get(i).getScore());
                String nativeByte = CLibrary.Instance.NLPIR_GetKeyWords(mapList.get(i).getDiscuss(),
                        10, false);

                List<String> res = new ArrayList<>();
                System.out.println("关键词提取结果是：" + nativeByte);
                String[] result = nativeByte.split("#");
                String score = mapList.get(i).getScore().toString();
                if ("1.0".equals(score)) {
                    for (int j = 0; j < result.length; j++) {
                        res.add(result[j]);
                    }
                    TxtUtils.writeToFile(res, type1);
                } else if ("2.0".equals(score)) {
                    for (int j = 0; j < result.length; j++) {
                        res.add(result[j]);
                    }
                    TxtUtils.writeToFile(res, type2);
                } else if ("3.0".equals(score)) {
                    for (int j = 0; j < result.length; j++) {
                        res.add(result[j]);
                    }
                    TxtUtils.writeToFile(res, type3);
                } else if ("4.0".equals(score)) {
                    for (int j = 0; j < result.length; j++) {
                        res.add(result[j]);
                    }
                    TxtUtils.writeToFile(res, type4);
                } else if ("5.0".equals(score)) {
                    for (int j = 0; j < result.length; j++) {
                        res.add(result[j]);
                    }
                    TxtUtils.writeToFile(res, type5);
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }finally{
                
            }
        }
    }
}
